import { deleteDepartmentApi } from "@/api/client/configCenter/accountManagement";
import { message } from "ant-design-vue";

export default function OperationHook(state: Base.GeneraDataType) {
  const { dialogOpts } = state;
  const addHandle = () => {
    dialogOpts.title = "新增部门";
    dialogOpts.width = "520px";
    dialogOpts.component = "AddDepartment";
    dialogOpts.type = 1;
    dialogOpts.visible = true;
  };
  const editHandle = (row: { id: string; name: string }) => {
    dialogOpts.title = "编辑部门";
    dialogOpts.width = "520px";
    dialogOpts.component = "AddDepartment";
    dialogOpts.passData = row;
    dialogOpts.type = 2;
    dialogOpts.visible = true;
  };
  const deleteHandle = (row: Base.GeneraDataType) => {
    deleteDepartmentApi({ id: row.id }).then((res: any) => {
      const { code } = res;
      if (code === 200) {
        message.success("操作成功!");
      }
    });
  };
  return {
    addHandle,
    deleteHandle,
    editHandle
  };
}
